package com.example.liqm.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SwitchButton switchButton = (SwitchButton) findViewById(R.id.switch_btn);

        switchButton.setSlideBitmap(R.mipmap.ic_slide);
        switchButton.setBackgroudBitmap(R.mipmap.ic_backgroud);

        //设置状态改变的接口回调
        switchButton.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(SwitchButton button, boolean isChecked) {
                Toast.makeText(MainActivity.this, "开关打开了", Toast.LENGTH_SHORT).show();
            }
        });

        //设置开启的状态
       // switchButton.setChecked(true);

    }


}
